package Pre.Work;

import java.util.Objects;
import java.util.Vector;

public class Exam03 {
    //创建⼀个Vector集合，⽤于存储⼀组整数。编写⼀个函数，接受⼀个整数并返回在Vector中出现的次数。
    private int num;

    public Exam03(int num) {
        this.num = num;
    }

    public int getNum() {
        return num;
    }


}
class Test01{
    public static void main(String[] args) {
        Vector vector = new Vector();
        vector.add(new Exam03(10));
        vector.add(new Exam03(18));
        vector.add(new Exam03(15));
        vector.add(new Exam03(12));
        vector.add(new Exam03(15));
        vector.add(new Exam03(12));
        vector.add(new Exam03(10));
        vector.add(new Exam03(18));
        vector.add(new Exam03(12));
        vector.add(new Exam03(10));
        System.out.println(Count(vector,10));
    }

    public static int Count(Vector vector,int num){
        int count = 0;
        for (int i = 0; i < vector.size()  ; i++) {
            Exam03 number = (Exam03) vector.get(i);
            if (Objects.equals(number.getNum(),num)){
                count ++;
            }
        }
        return count;
    }
}